$(function() {   
  $(".submitapp").click(function() {   
    // validate and process form here   
	var appstatus = $("input#appstatus").val();  
	if (appstatus == "1") {   
		var appdecision = $("input#appdecision").val();  
		if(appdecision=="3"){
			var scheduledpayday = $("input#scheduledpayday").val();  
			if (scheduledpayday == "") {   
	    			alert("Please endter the scheduled pay day");
				return false;   
			}
			var setuppadday = $("input#setuppadday").val();  
			if (setuppadday == "") {   
		    		alert("Please enter the setup PAD day");
				return false;   
			}
			var approvedcredits = $("select#approvedcredits").val();  
			if (approvedcredits == "0") {   
	    			alert("Please select the credit you would like to approve for this applicant");
				return false;   
			}			
			var A_padamount = $("input#A_padamount").val();  
			if (A_padamount == "2") {   
				var padamount1 = $("input#padamount1").val();  
				if (padamount1 == "") {   
	    				alert("Please enter the first payment amount");
					return false;   
				}			
				var padamount2 = $("input#padamount2").val();  
				if (padamount2 == "") {   
	    				alert("Please enter the second payment amount");
					return false;   
				}			
			} else if (A_padamount == "3") {   
				var padamount1 = $("input#padamount1").val();  
				if (padamount1 == "") {   
	    				alert("Please enter the first payment amount");
					return false;   
				}			
				var padamount2 = $("input#padamount2").val();  
				if (padamount2 == "") {   
	    				alert("Please enter the second payment amount");
					return false;   
				}			
				var padamount3 = $("input#padamount3").val();  
				if (padamount3 == "") {   
	    				alert("Please enter the third payment amount");
					return false;   
				}			

			} else if (A_padamount == "4") {   
				var padamount1 = $("input#padamount1").val();  
				if (padamount1 == "") {   
	    				alert("Please enter the first payment amount");
					return false;   
				}			
				var padamount2 = $("input#padamount2").val();  
				if (padamount2 == "") {   
	    				alert("Please enter the second payment amount");
					return false;   
				}			
				var padamount3 = $("input#padamount3").val();  
				if (padamount3 == "") {   
	    				alert("Please enter the third payment amount");
					return false;   
				}			
				var padamount4 = $("input#padamount4").val();  
				if (padamount4 == "") {   
	    				alert("Please enter the fourth payment amount");
					return false;   
				}			
			} else if (A_padamount == "5") {   
				var padamount1 = $("input#padamount1").val();  
				if (padamount1 == "") {   
	    				alert("Please enter the first payment amount");
					return false;   
				}			
				var padamount2 = $("input#padamount2").val();  
				if (padamount2 == "") {   
	    				alert("Please enter the second payment amount");
					return false;   
				}			
				var padamount3 = $("input#padamount3").val();  
				if (padamount3 == "") {   
	    				alert("Please enter the third payment amount");
					return false;   
				}			
				var padamount4 = $("input#padamount4").val();  
				if (padamount4 == "") {   
	    				alert("Please enter the fourth payment amount");
					return false;   
				}			
				var padamount5 = $("input#padamount5").val();  
				if (padamount5 == "") {   
	    				alert("Please enter the fifth payment amount");
					return false;   
				}			
			} else if (A_padamount == "6") {   
				var padamount1 = $("input#padamount1").val();  
				if (padamount1 == "") {   
	    				alert("Please enter the first payment amount");
					return false;   
				}			
				var padamount2 = $("input#padamount2").val();  
				if (padamount2 == "") {   
	    				alert("Please enter the second payment amount");
					return false;   
				}			
				var padamount3 = $("input#padamount3").val();  
				if (padamount3 == "") {   
	    				alert("Please enter the third payment amount");
					return false;   
				}			
				var padamount4 = $("input#padamount4").val();  
				if (padamount4 == "") {   
	    				alert("Please enter the fourth payment amount");
					return false;   
				}			
				var padamount5 = $("input#padamount5").val();  
				if (padamount5 == "") {   
	    				alert("Please enter the fifth payment amount");
					return false;   
				}			
				var padamount6 = $("input#padamount6").val();  
				if (padamount6 == "") {   
	    				alert("Please enter the sixth payment amount");
					return false;   
				}			
			} else if (A_padamount == "7") {   
				var padamount1 = $("input#padamount1").val();  
				if (padamount1 == "") {   
	    				alert("Please enter the first payment amount");
					return false;   
				}			
				var padamount2 = $("input#padamount2").val();  
				if (padamount2 == "") {   
	    				alert("Please enter the second payment amount");
					return false;   
				}			
				var padamount3 = $("input#padamount3").val();  
				if (padamount3 == "") {   
	    				alert("Please enter the third payment amount");
					return false;   
				}			
				var padamount4 = $("input#padamount4").val();  
				if (padamount4 == "") {   
	    				alert("Please enter the fourth payment amount");
					return false;   
				}			
				var padamount5 = $("input#padamount5").val();  
				if (padamount5 == "") {   
	    				alert("Please enter the fifth payment amount");
					return false;   
				}			
				var padamount6 = $("input#padamount6").val();  
				if (padamount6 == "") {   
	    				alert("Please enter the sixth payment amount");
					return false;   
				}			
				var padamount7 = $("input#padamount7").val();  
				if (padamount7 == "") {   
	    				alert("Please enter the seventh payment amount");
					return false;   
				}			
			} else if (A_padamount == "8") {   
				var padamount1 = $("input#padamount1").val();  
				if (padamount1 == "") {   
	    				alert("Please enter the first payment amount");
					return false;   
				}			
				var padamount2 = $("input#padamount2").val();  
				if (padamount2 == "") {   
	    				alert("Please enter the second payment amount");
					return false;   
				}			
				var padamount3 = $("input#padamount3").val();  
				if (padamount3 == "") {   
	    				alert("Please enter the third payment amount");
					return false;   
				}			
				var padamount4 = $("input#padamount4").val();  
				if (padamount4 == "") {   
	    				alert("Please enter the fourth payment amount");
					return false;   
				}			
				var padamount5 = $("input#padamount5").val();  
				if (padamount5 == "") {   
	    				alert("Please enter the fifth payment amount");
					return false;   
				}			
				var padamount6 = $("input#padamount6").val();  
				if (padamount6 == "") {   
	    				alert("Please enter the sixth payment amount");
					return false;   
				}			
				var padamount7 = $("input#padamount7").val();  
				if (padamount7 == "") {   
	    				alert("Please enter the seventh payment amount");
					return false;   
				}			
				var padamount8 = $("input#padamount8").val();  
				if (padamount8 == "") {   
	    				alert("Please enter the eighth payment amount");
					return false;   
				}			
			} else if (A_padamount == "9") {   
				var padamount1 = $("input#padamount1").val();  
				if (padamount1 == "") {   
	    				alert("Please enter the first payment amount");
					return false;   
				}			
				var padamount2 = $("input#padamount2").val();  
				if (padamount2 == "") {   
	    				alert("Please enter the second payment amount");
					return false;   
				}			
				var padamount3 = $("input#padamount3").val();  
				if (padamount3 == "") {   
	    				alert("Please enter the third payment amount");
					return false;   
				}			
				var padamount4 = $("input#padamount4").val();  
				if (padamount4 == "") {   
	    				alert("Please enter the fourth payment amount");
					return false;   
				}			
				var padamount5 = $("input#padamount5").val();  
				if (padamount5 == "") {   
	    				alert("Please enter the fifth payment amount");
					return false;   
				}			
				var padamount6 = $("input#padamount6").val();  
				if (padamount6 == "") {   
	    				alert("Please enter the sixth payment amount");
					return false;   
				}			
				var padamount7 = $("input#padamount7").val();  
				if (padamount7 == "") {   
	    				alert("Please enter the seventh payment amount");
					return false;   
				}			
				var padamount8 = $("input#padamount8").val();  
				if (padamount8 == "") {   
	    				alert("Please enter the eighth payment amount");
					return false;   
				}			
				var padamount9 = $("input#padamount9").val();  
				if (padamount9 == "") {   
	    				alert("Please enter the ninth payment amount");
					return false;   
				}	
			} else if (A_padamount == "10") {   
				var padamount1 = $("input#padamount1").val();  
				if (padamount1 == "") {   
	    				alert("Please enter the first payment amount");
					return false;   
				}			
				var padamount2 = $("input#padamount2").val();  
				if (padamount2 == "") {   
	    				alert("Please enter the second payment amount");
					return false;   
				}			
				var padamount3 = $("input#padamount3").val();  
				if (padamount3 == "") {   
	    				alert("Please enter the third payment amount");
					return false;   
				}			
				var padamount4 = $("input#padamount4").val();  
				if (padamount4 == "") {   
	    				alert("Please enter the fourth payment amount");
					return false;   
				}			
				var padamount5 = $("input#padamount5").val();  
				if (padamount5 == "") {   
	    				alert("Please enter the fifth payment amount");
					return false;   
				}			
				var padamount6 = $("input#padamount6").val();  
				if (padamount6 == "") {   
	    				alert("Please enter the sixth payment amount");
					return false;   
				}			
				var padamount7 = $("input#padamount7").val();  
				if (padamount7 == "") {   
	    				alert("Please enter the seventh payment amount");
					return false;   
				}			
				var padamount8 = $("input#padamount8").val();  
				if (padamount8 == "") {   
	    				alert("Please enter the eighth payment amount");
					return false;   
				}			
				var padamount9 = $("input#padamount9").val();  
				if (padamount9 == "") {   
	    				alert("Please enter the ninth payment amount");
					return false;   
				}			
				var padamount10 = $("input#padamount10").val();  
				if (padamount10 == "") {   
	    				alert("Please enter the tenth payment amount");
					return false;   
				}			
			}
		}

	} else if (appstatus == "3") {   
		var A_payment = $("input#A_payment").val();  
		if(A_payment=="4"){
			var newpayamount = $("input#newpayamount").val();  
			if (newpayamount == "") {   
	    			alert("Please enter new pay amount");
				return false;   
			}
			var partialpay = $("input#partialpay").val();  
			if (partialpay == "") {   
		    		alert("Please enter the paid amount, if no, enter 0");
				return false;   
			}
			var newpadday = $("input#newpadday").val();  
			if (newpadday == "") {   
	    			alert("Please enter the new PAD day for the collection");
				return false;   
			}
		} else if(A_payment=="8"){
			var defaultreason = $("select#defaultreason").val();  
			if (defaultreason == "") {   
	    			alert("Please select the default reason");
				return false;   
			}
		} else if(A_payment=="9"){
			var newpayamount = $("input#newpayamount").val();  
			if (newpayamount == "") {   
	    			alert("Please endter new pay amount");
				return false;   
			}
			var partialpay = $("input#partialpay").val();  
			if (partialpay == "") {   
		    		alert("Please enter the paid amount, if no, enter 0");
				return false;   
			}			
		}			

	} else if (appstatus == "7") {   
		var ftpfilefunction = $("input#ftpfilefunction").val();  
		if(ftpfilefunction=="1"){
			var morningafternoon = $("select#morningafternoon").val();  
			if (morningafternoon == "0") {   
	    			alert("Please select morning run or afternoon run");
				return false;   
			}

			var padpds = $("select#padpds").val();  
			if (padpds == "") {   
	    			alert("Please select to generate PDS only or both PAD and PDS");
				return false;   
			}
			
		} else if(ftpfilefunction=="2"){
			var morningafternoon = $("select#morningafternoon").val();  
			if (morningafternoon == "0") {   
	    			alert("Please select morning run or afternoon run");
				return false;   
			}			
			var rundate = $("input#rundate").val();  
			if (rundate == "") {   
	    			alert("Please enter the run date");
				return false;   
			}
			var padpds = $("select#padpds").val();  
			if (padpds == "") {   
	    			alert("Please select to generate PDS only or both PAD and PDS");
				return false;   
			}
		} 
	}
	
  });  

});   




